﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;
using ATSV.Web.Services;
using System.ServiceModel.DomainServices.Client;
using ATSV.Web;

namespace ATSV.Views
{
    public partial class Home : Page
    {
        private ATSVDataContext dc = new ATSVDataContext();
        
        public Home()
        {
            InitializeComponent();

            
        }

        // Executes when the user navigates to this page.
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            
            //IEnumerable<NewsItemSet> news = this.dc.Load(this.dc.GetNewsItemSetsQuery()).Entities.OrderByDescending(n => n.CreateDate);

            //IEnumerable<NewsItemSet> sets = dc.NewsItemSets;
            //dc.Load(dc.GetNewsItemSetsQuery());


            //foreach (NewsItemSet item in news)
            //{
            //    NewsItem ni = new NewsItem();
            //    ni.DataContext = item;
            //    this.newsScroller.Children.Add(ni);
            //}

            //newsScroller.Children.Add(new NewsItem("test", "test test tes tetstasdkjasd aslkdnaöksdfjbas dmlnasfcöjansdhkösqjnd"));
        }

        private void newsItemSetDomainDataSource_LoadedData(object sender, LoadedDataEventArgs e)
        {

            if (e.HasError)
            {
                System.Windows.MessageBox.Show(e.Error.ToString(), "Load Error", System.Windows.MessageBoxButton.OK);
                e.MarkErrorAsHandled();
            }
        }

        private void AdminButton_Click(object sender, RoutedEventArgs e)
        {
            AdminCockpit ac = new AdminCockpit();

            ac.Show();
        }

       
    }
}
